
clear
capture: log close
pause on
set more off
cd "/Users/thomasjamieson/Dropbox/Academic/Working Papers/Disaster Lobbying"

/**************************************** 
Figure 1 
*****************************************/

clear
use "merged.dta"

graph twoway spike count report_year, yaxis(1) lcolor(gs11) lwidth(vvthick) || line total_count report_year, yaxis(2)  lpattern(dash) lcolor(gs4) lwidth(medthick) 

graph twoway spike million report_year, yaxis(1) lcolor(gs11) lwidth(vvthick) || line total_million report_year, yaxis(2)  lpattern(dash) lcolor(gs4) lwidth(medthick) 

/***************************************
Table 1 - Testing Hypotheses 1 & 2 
****************************************/

clear
use "merged.dta"
eststo clear

/* Column 1 */

reg count NumberofMajorDisasterDeclaration appropriations TotalProjectedFEMACostsofCatastr total_count, r
coefplot, drop(_cons) xline(0, lpattern(dash) lcolor(black)) graphregion(fcolor(white)) lcolor(black) msize(small) graphregion(color(white)) mcolor(black) ciopts(lcolor(black)) subtitle("Number of Lobbying Reports", margin(small))
estimates store c1, title(column 1)

/* Column 2 */

reg top20_count NumberofMajorDisasterDeclaration appropriations TotalProjectedFEMACostsofCatastr total_count, r
coefplot, drop(_cons) xline(0, lpattern(dash) lcolor(black)) graphregion(fcolor(white)) lcolor(black) msize(small) graphregion(color(white)) mcolor(black) ciopts(lcolor(black)) subtitle("Number of Lobbying Reports", margin(small))
estimates store c2, title(column 2)

/* Column 3 */

reg rest_count NumberofMajorDisasterDeclaration appropriations TotalProjectedFEMACostsofCatastr total_count, r
coefplot, drop(_cons) xline(0, lpattern(dash) lcolor(black)) graphregion(fcolor(white)) lcolor(black) msize(small) graphregion(color(white)) mcolor(black) ciopts(lcolor(black)) subtitle("Number of Lobbying Reports", margin(small))
estimates store c3, title(column 3)

/* Column 4 */

reg million NumberofMajorDisasterDeclaration appropriations TotalProjectedFEMACostsofCatastr total_million, r
coefplot, drop(_cons) xline(0, lpattern(dash) lcolor(black)) graphregion(fcolor(white)) lcolor(black) msize(small) graphregion(color(white)) mcolor(black) ciopts(lcolor(black)) subtitle("Money Spent on Lobbying (USD Million)", margin(small))
estimates store c4, title(column 4)

/* Column 5 */

reg top20 NumberofMajorDisasterDeclaration appropriations TotalProjectedFEMACostsofCatastr total_million, r
coefplot, drop(_cons) xline(0, lpattern(dash) lcolor(black)) graphregion(fcolor(white)) lcolor(black) msize(small) graphregion(color(white)) mcolor(black) ciopts(lcolor(black)) subtitle("Money Spent on Lobbying (USD Million)", margin(small))
estimates store c5, title(column c5)

/* Column 6 */

reg rest NumberofMajorDisasterDeclaration appropriations TotalProjectedFEMACostsofCatastr total_million, r
coefplot, drop(_cons) xline(0, lpattern(dash) lcolor(black)) graphregion(fcolor(white)) lcolor(black) msize(small) graphregion(color(white)) mcolor(black) ciopts(lcolor(black)) subtitle("Money Spent on Lobbying (USD Million)", margin(small))
estimates store c6, title(column c6)

/*Building the Table*/
esttab c1 c2 c3 c4 c5 c6 using "table1.rtf", b(3) replace unstack nobaselevels label nogap se star (+ 0.1 * 0.05 ** 0.01 *** 0.001) r2 title({Determinants of Lobbying in Emergency Management.}\label{tab1})


/***************************************
Figure 2 
****************************************/

clear
use "descriptive_lobbyists.dta"

collapse (sum) million, by(registrant_name)
sort million

graph hbar million if million>14, nofill over(registrant_name, sort(million) lab(labsize(tiny))) legend(off) ytitle("USD Million") yscale(lstyle(none)) 


/***************************************
Figure 3
****************************************/

clear
use "donoryear_scatterplot.dta"

twoway (scatter million report_year if registrant_name == "NATIONAL ASSOCIATION OF REALTORS" & million>10, mlabel(registrant_name) msize(tiny) mlabsize(relative1p2) mlabvposition(pos)) (scatter million report_year if registrant_name == "CHAMBER OF COMMERCE OF THE U.S.A." & million>10, mlabel(registrant_name) msize(tiny) mlabsize(relative1p2) mlabvposition(pos)) (scatter million report_year if registrant_name == "FACEBOOK, INC. AND VARIOUS SUBSIDIARIES (FORMERLY REPORTING AS FACEBOOK, INC.)" & million>10, mlabel(registrant_name) msize(tiny) mlabsize(relative1p2) mlabvposition(pos) ) (scatter million report_year if million<10, msize(tiny)), ytitle("Money Spent on Lobbying (USD Million), by Donor and Year") xtitle("")  legend(label(1 "NATIONAL ASSOCIATION OF REALTORS") label(2 "CHAMBER OF COMMERCE OF THE U.S.A.") label(3 "FACEBOOK, INC. AND VARIOUS SUBSIDIARIES") label(4 "LESS THAN 10 USD MILLION") size(vsmall))


/***************************************
Figure 4
****************************************/

clear
use "descriptive.dta"
keep if issue_code == "DIS"

keep issue_text

export delimited issue_text.txt, delimiter(tab) replace

ssc install wordcloud

wordfreq using "issue_text.txt"

drop if length(word) <= 2
drop if word == "and"
drop if word == "for"
drop if word == "the"
drop if word == "with"
drop if word == "amp"
drop if word == "that"


wordcloud word freq, min_length(4) nonumbers nogrammar nowww nocommon style(1) 

graph hbar freq if freq>449, nofill over(word, sort(freq) lab(labsize(tiny))) legend(off) ytitle("Word Frequency") yscale(lstyle(none)) 
